﻿using SmartSapce.ServiceLocation;
using SmartSpace.Core;
using SmartSpace.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SmartSpace.WebApp
{
    public partial class _dynamic : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected override void OnPreInit(EventArgs e)
        {
            ICoreService service = ServiceLocator.Get<ICoreService>();
            Site application = service.GetSites()[0];
            _ctlApplicationName.Text = application.Title;
            _ctlApplicationShortName.Text = application.ShortTitle;

            this.Theme = "DarkBlue";

            string pageName = Request.QueryString["__page"];

            SmartSpace.Core.Page page = service.GetPage(SsSite.Current.Id, pageName);

            _ctlPanel.Controls.Add(this.LoadControl("~/_templates/_page/" + page.Template.Code + ".ascx"));

            base.OnPreInit(e);
        }
    }
}